local thbattle__shennaizi_xinyang = fk.CreateSkill {

  name = "thbattle__shennaizi_xinyang",

  tags = { Skill.Limited, },

}



thbattle__shennaizi_xinyang:addEffect("active", {
  anim_type = "big",
  prompt = "#thbattle__shennaizi_xinyang",
  can_use = function(self, player, card, extra_data)
    local room = Fk:currentRoom()
    return #table.filter(room.alive_players, function(p)
      return player:inMyAttackRange(p)
    end) > 0 and player:usedSkillTimes(thbattle__shennaizi_xinyang.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local targetplayers = table.filter(room:getOtherPlayers(player), function(p)
      return player:inMyAttackRange(p)
    end)
    for _, p1 in ipairs(targetplayers) do
      room:doIndicate(player, { p1 })
      if player:isNude() then
        player:drawCards(1, thbattle__shennaizi_xinyang.name)
      else
        local choice1 = room:askForChoice(p1,
          { "#thbattle__shennaizi_xinyang-draw:" .. player.id, "#thbattle__shennaizi_xinyang-discard:" ..
          player.id }, thbattle__shennaizi_xinyang.name)
        if choice1 == "#thbattle__shennaizi_xinyang-draw:" .. player.id then
          player:drawCards(1, thbattle__shennaizi_xinyang.name)
        else
          local discard = room:askForCardChosen(p1, player, "he", thbattle__shennaizi_xinyang.name,
            "#thbattle__shennaizi_xinyang-choose_discard:" .. player.id)
          room:throwCard(discard, thbattle__shennaizi_xinyang.name, player, p1)
          local choice2 = room:askForChoice(player,
            { "#thbattle__shennaizi_xinyang-use_slash::" .. p1.id, "cancel" }, thbattle__shennaizi_xinyang.name)
          if choice2 ~= "cancel" then
            room:useCard({
              from = player,
              tos = {p1 },
              card = Fk:cloneCard("danmu__slash"),
              extraUse = true,
            })
          end
        end
      end
    end
  end,
})

return thbattle__shennaizi_xinyang